import { bind } from "../../core/module/proxy/ProxyDecorator";
import { LobbyProxy } from "../../script/proxy/LobbyProxy";
import { app } from "../../script/app/App";
import { UIBase } from "../../core/module/ui/UIBase";
import { SceneEnum } from "../../script/share/Enum";
@bind(LobbyProxy)
export class Lobby extends UIBase<LobbyProxy> {
    onInit(): void {
        this._view.btnEnter.onClick(this, this._onMatchRoomClick)
    }

    onShow(): void {
        super.onShow()
        this._view.userId.string = app.model.user.userId + ''
        this._view.nickname.string = app.model.user.nickname
    }

    onCover(proxyName: string): void {
        this._view.node.active = true
    }

    private _onMatchRoomClick() {
        app.model.lobby.matchRoomReq(() => {
            app.model.game.enterRoomReq(app.model.user.userId, () => {
                app.scene.startScene(SceneEnum.Game)
            })
        })
    }
}